<?php
/**
 * beimuaihui System
 * Copyright(c) 2011-2020 beimuaihui.
 * @license    http://www.gnu.org/licenses/gpl.html     This software Under GPL V3 License 
 * beimuaihui@gmail.com
 * http://code.google.com/p/beimuaihui/
 * $Id: ArticleController.php 197 2011-02-18 12:45:33Z beimuaihui $
 */

require_once 'Zend/Controller/Action.php';

class Blog_ArticleController extends Baogg_Controller_Action {
	public function init(){
		Zend_Loader::loadClass("Article");
		$this->article=new Article();
	}
	/**
	 * The default action - show the home page
	 */
	public function indexAction() {
		
	}
	public function listAction(){
		$this->view->data= $this->article->getList(array("a.state=1"));
		
	}
	public function viewAction(){
		$params=Baogg_Controller::getUrlParams();
		$article_id=(int)$params['article_id'];
		$where=array("a.article_id=".$article_id);
		$this->view->data=$this->article->getList($where);
	}
	public function lastestAction() {
		$this->view->data= $this->article->getList(array("a.state=1"),null,array("offset"=>0,"size"=>10));
	}
	public function addAction() {
		Zend_Loader::loadClass("Tag");
		$tag=new Tag();
		$arr_tag=$tag->getList(array("a.state=1"));
		$map_tag=array();
		foreach((array)$arr_tag as $v){
			$map_tag[$v['tag_id']]=$v['tag_name'];
		}
		$form ['myForm'] = array ('action'=>BAOGG_BASE_URL."blog/article/addsave/");
		$form ['myFld'] = array ('legend' =>  " ADD" , 'pid' => 'myForm' );
		$form ['title'] = array ('class' => '', 'pid' => 'myFld' );
		$form ['tag_id'] = array ('tag'=>'select','class' => '', 'pid' => 'myFld','data'=>$map_tag );
		$form ['ordering'] = array ('class' => '', 'pid' => 'myFld' );
		$form ['state'] = array ('class' => '', 'pid' => 'myFld', 'tag' => 'radio', 'data' => Translate::$aState );
		$form ['content'] = array ('tag'=>'div','label'=>false,'dojoType'=>"dijit.Editor",'extraPlugins'=>'["|", "insertHorizontalRule"]','class' => '', 'pid' => 'myFld' );
		$form ['submit'] = array ('label' => false, 'type' => 'submit', 'pid' => 'myFld' );
		$form ['reset'] = array ('label' => false, 'type' => 'reset', 'plugin' => 'submit:3' );
		
		//$tran=array_fill_keys(array_keys($form),'');var_export($tran);exit;
		Zend_Loader::loadClass ( "Baogg_View_Form" );
		$form = new Baogg_View_Form ( $form );
		$this->view->form = $form;
	}
	public function addsaveAction(){
		$params=Baogg_Controller::getUrlParams();
		Zend_Loader::loadClass("Article");
		$article=new Article();
		$this->view->flag=$article->add($params);
		//$this->_helper->viewRenderer->setNoRender ();
	}
	public function rightsAction() {
	
	}
	public function bodyAction() {
	
	}
}
